﻿<UserControl x:Class="SettingsModelWPFDemo.Views.SettingsPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             
             DataContext="{Binding SettingsPage}"
             >
    <Grid Style="{StaticResource ContentRoot}"
          xmlns:viewmodel="clr-namespace:SettingsModelWPFDemo.ViewModels.SettingPages"
          xmlns:views="clr-namespace:SettingsModelWPFDemo.Views.SettingsPages"
          >
        <Grid.Resources>
            <DataTemplate DataType="{x:Type viewmodel:GeneralViewModel}">
                <views:General />
            </DataTemplate>

            <DataTemplate DataType="{x:Type viewmodel:AppearanceViewModel}">
                <views:Appearance />
            </DataTemplate>

            <DataTemplate DataType="{x:Type viewmodel:AboutViewModel}">
                <views:About />
            </DataTemplate>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        
        <ListBox Grid.Column="0"
                 ItemsSource="{Binding Pages}"
                 SelectedItem="{Binding SelectedPage}"
                 >
            <ListBox.ItemTemplate>
                <DataTemplate xmlns:conv="clr-namespace:SettingsModelWPFDemo.Converters"
                    >
                    <DataTemplate.Resources>
                            <conv:UpperCaseDateConverter x:Key="UpperCaseDateConverter" />
                    </DataTemplate.Resources>
                    <TextBlock Margin="9,3"
                               Text="{Binding DisplayTitle, Converter={StaticResource UpperCaseDateConverter}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Border Grid.Column="1" VerticalAlignment="Stretch"
                Margin="0"
                BorderBrush="{DynamicResource Accent}" BorderThickness="1">
        </Border>

        <Grid Grid.Column="2">
            <ContentPresenter Content="{Binding SelectedPage, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
                                Margin="32,0,0,0"
                                />
        </Grid>
    </Grid>
</UserControl>
